#include<stdio.h>
#include<stdlib.h>
#define size 10000
int beg[size],end[size],dp[size+1];
/*
15 6
1 2
1 6
4 11
8 5
8 1
11 5

4*/ 
int main(void)
{
    //freopen("works.in","r",stdin);
    //freopen("works.out","w",stdout);
    int time = 0,many = 0,i = 0,j = 0;
    
    fscanf(stdin,"%d %d",&time,&many);
    j = many;
    
    for(i = 1;i <= many;i++)
        scanf("%d %d",&beg[i],&end[i]);
    for(i = time;i > 0;i--)
    {
        if(i != beg[j])
            dp[i] = dp[i+1]+1;
        else
            while(beg[j] == i)
            {
                if(dp[i] < dp[beg[j]+end[j]])
                    dp[i] = dp[beg[j]+end[j]];
                j--;
            }
    }           
    printf("%d\n",dp[1]);
    return 0;
}
